package com.guli.gulikiller.killer.controller;

import java.util.Arrays;
import java.util.Map;

import com.guli.common.utils.PageUtils;
import com.guli.common.utils.R;
import com.guli.gulikiller.killer.entity.StockEntity;
import com.guli.gulikiller.killer.service.StockService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2022-05-27 09:51:41
 */
@RestController
@RequestMapping("generator/stock")
@Api("")
public class StockController {
    @Autowired
    private StockService stockService;

    /**
     * 列表
     */
    @PostMapping("/list")
    //@RequiresPermissions("generator:stock:list")
    @ApiOperation("查询")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = stockService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @PostMapping("/info/{id}")
    @ApiOperation("根据id查询")
    public R info(@PathVariable("id") Integer id){
		StockEntity stock = stockService.getById(id);

        return R.ok().put("stock", stock);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    //@RequiresPermissions("generator:stock:save")
    @ApiOperation("保存")
    public R save(@RequestBody StockEntity stock){
		stockService.save(stock);

        return R.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    @ApiOperation("修改")
    //@RequiresPermissions("generator:stock:update")
    public R update(@RequestBody StockEntity stock){
		stockService.updateById(stock);

        return R.ok();
    }

    /**
     * 删除
     */
    @PostMapping("/delete")
   // @RequiresPermissions("generator:stock:delete")
    @ApiOperation("删除")
    public R delete(@RequestBody Integer[] ids){
		stockService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
